﻿
#region Usings

using FasterWPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FasterWPF.Selectors;

#endregion

namespace FasterWPFDemo
{
    public static class TestSelectorsEngineService
    {
        //Try out the Selectors Engine method calls

        public static void Run(Window window)
        {
            //Dictionary<string, object> windowChildren = window.GetChildLookupDictionary<FrameworkElement>();
            List<FrameworkElement> aggregateChildren = window.SelectAllFrameworkElements(false);

            window.ActOnAllFrameworkElementsByClass("tabItem3", false, 
                fe => { (fe as Control).Foreground = Brushes.Black; (fe as Control).FontSize = 14; });

            window.ActOnAllFrameworkElementsByClass("tabItem3", "bold", false, 
                fe => { (fe as Control).Foreground = Brushes.Black; (fe as Control).FontWeight = FontWeights.Bold; });

            window.ActOnAllFrameworkElementsByClass("tabItem3", "bold", "italic", false, 
                fe => { (fe as Control).Foreground = Brushes.Black; (fe as Control).FontWeight = FontWeights.Bold; (fe as Control).FontStyle = FontStyles.Italic; });

            window.ActOnAllFrameworkElementsByClass("mainLabels", false, 
                fe => { (fe as Control).Foreground = Brushes.White; (fe as Control).Background = Brushes.Navy; (fe as Label).BorderBrush = Brushes.GhostWhite; });

            window.ActOnAllFrameworkElementsByClass("tabLabel", false, 
                fe => { (fe as Label).FontSize = 17D; });

            GroupBox groupBoxNestedInTabItem2 = window.SelectCompositeByName<GroupBox>("myGroupBox");

            if (groupBoxNestedInTabItem2 != null)
            {
                groupBoxNestedInTabItem2.SelectFrameworkElementsByType<TextBlock>().ForEach(
                    tblck => { tblck.UpdateSelectorClass(SettingsManager.SelectorPosition.One, "customTextBlock"); });
            }

            window.ActOnAllFrameworkElementsByClass("customTextBlock", false, 
                fe => { (fe as TextBlock).FontSize = 11D; (fe as TextBlock).Background = Brushes.Goldenrod; });

            //Selectors Engine Examples
            //   List<TextBox> textBoxChildren = window.SelectFrameworkElementsByType<TextBox>();
            //   textBoxChildren.ForEach(txb => { txb.SetBackgroundColor(Brushes.Goldenrod); });

            List<FrameworkElement> felist1 = window.SelectParentFrameworkElementsOnly(false);
            List<FrameworkElement> felist2 = window.SelectChildFrameworkElementsOnly(false);
            List<FrameworkElement> felist3 = window.SelectAllFrameworkElements(false);
            List<Grid> felist4 = window.SelectContainersFromAllTComposites<Grid>(ContainerType.Grid, false);
            List<Border> felist5 = window.SelectCompositesOnly(false);
        }
    }
}
